using System;
using System.Collections.Generic;
using BBX.Common;
using BBX.Entity;
using BBX.Forum;

namespace BBX.Web
{
    public class myattachment : PageBase
    {
        public IList<MyAttachment> myattachmentlist;
        public Int32 pageid = DNTRequest.GetInt("page", 1);
        public Int32 pagecount;
        public Int32 attachmentcount;
        public String pagenumbers;
        public IUser user;
        public Int32 typeid = DNTRequest.GetInt("typeid", 0);

        protected override void ShowPage()
        {
            pagetitle = "用户控制面板";
            if (userid == -1)
            {
                base.AddErrLine("你尚未登录");
                return;
            }
            user = Users.GetUserInfo(userid);
            attachmentcount = MyAttachment.SearchCount(userid, typeid);
            pagecount = ((attachmentcount % 16 == 0) ? (attachmentcount / 16) : (attachmentcount / 16 + 1));
            pagecount = ((pagecount == 0) ? 1 : pagecount);
            pageid = ((pageid < 1) ? 1 : pageid);
            pageid = ((pageid > pagecount) ? pagecount : pageid);
            myattachmentlist = MyAttachment.Search(userid, typeid, null, (pageid - 1) * 16, 16);
            pagenumbers = Utils.GetPageNumbers(pageid, pagecount, (typeid > 0) ? ("myattachment.aspx?typeid=" + typeid) : "myattachment.aspx", 10);
        }
    }
}